import timLogin from '@/utils/timLogin.js'
export default {
  data() {
    return {
      price: '',
      bookid: '', //预约订单id
      madAppList: {}, //预约详情
      madappStatus: '', //状态
      xedColorList: {
        outerColour: {
          colorCoding: '',
          color: ''
        },
        inColour: {
          colorCoding: '',
          color: '',
          neiColor: [{}]
        }
      }, //选择的颜色集合
      judgeColor: false, //判断颜色是否存在
      showPage: false
    }
  },
  onLoad(caridxix) {
    this.bookid = caridxix.bookid
    this.price = caridxix.price
    this.GetCarBookDetailInfo()
  },
  methods: {
    //店铺详情
    onStore(id){
		  uni.navigateTo({
		    url: '/pages_store/newCarStore/index/index?storeid='+id
		  })
    },
    // 客服电话
    onNavigationBarButtonTap(e) {
      uni.makePhoneCall({
        phoneNumber: '18080088254'
      })
    },
    //详情
    async GetCarBookDetailInfo() {
      try {
        const res = await this.$api.order.GetCarBookDetailInfo({
          bookId: this.bookid
        })
        this.showPage = true
        this.madAppList = res.data
        //预约状态(1、待到店 2、已到店 5、已取消)
        if (res.data.bookStatus === '1') {
          this.madappStatus = '待到店'
        } else if (res.data.bookStatus === '2') {
          this.madappStatus = '已到店'
        } else {
          this.madappStatus = '已取消'
        }
        this.xedColorList = JSON.parse(res.data.color)
        if (this.xedColorList.inColour.color === '') {
          this.judgeColor = false
        } else {
          this.judgeColor = true
        }
        this.xedColorList.inColour.neiColor = [{}]

        this.xedColorList.inColour = this.filtercolor(this.xedColorList.inColour) //内试颜色

        console.log(this.xedColorList)

      } catch (err) {}
    },
    //分割颜色
    filtercolor(data) {
      var arr = data.colorCoding.split('/')
      data.neiColor = arr
      return data
    },
    //复制到剪切板
    copyClick(value) {
      uni.setClipboardData({
        data: value
      })
    },
    // 拨打电话
    mobileclick(e) {
      uni.makePhoneCall({
        phoneNumber: e
      })
    },
    getCont(types){
      this.$store.commit('news/createConversationActive', {
			  user: types.storeName, //店铺名称
			  img: types.brandUrl, //店铺头像
			  lastTime: '', //
			  userId: types.storeId, //店铺id
			  conversationID: 'C2C' + types.storeId,
      })
      this.$store.commit('news/setCardInfo', {
			  imgSrc: types.brandUrl,
			  name: types.name,
			  price: this.price,
        tab: 0,
			  type: 'resaleCar',
        goPage: '1'
      })
      uni.navigateTo({
			  url: '/pages_common/contactSeller/contactSeller?user=' + types.storeName + '&pageId=' + this.bookid+ '&tab=0'
      })
    },
    imclick(types) {
      if (this.$store.state.isSDKReady) {
			  this.getCont(types)
      } else {
			  timLogin(() => {
			    this.getCont(types)
			  })
      }

    }
  }
}
